<?php
require("../inc/common.inc.php");
require("checkLogin.php");
$web_title="积分兑换记录";
if($type == 'ajax'){
	$str=" and userid=$mxuserid and type=2";
	if(empty($pageindex)){
		$pageindex=2;
	}
	$pagesize=intval($pagesize);
	if ($pagesize==0){
		$pagesize=10;
	}
	$order="order by createtime desc, id desc";
	$column=" * ";
	$biaoid="id";
	$list=$db->list1($pageindex,$pagesize,'mx_app_user_integral',$column,$str,$order,$biaoid);

	$status = 0;
	if($list){
		$status = 1;
		foreach($list as $k => $v){
			if($v['createtime']){
				$list[$k]['createtime'] = toDate($v['createtime']);
			}
		}
	}
	print_r(json_encode(array('status'=>$status,'data'=>$list)));
	exit();
}
$table = 'mx_app_user';
$info = $db->getinfo("select * from $table where id=$mxuserid");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1" name="viewport">
<title><?php echo $web_title?></title>
<meta name="searchtitle" content="<?php echo $webdb['description'];?>">
<meta name="description" content="<?php echo $webdb['description'];?>">
<meta name="keywords" content="<?php echo $webdb['metakeywords'];?>">
<meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta content="telephone=no, address=no" name="format-detection">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<?php $head_hide=1;require("../w_head.php")?>
</head>
<body>
<div id="ly_yifeng">积分兑换记录</div>

<div class="list_ban"><img src="/images/p2.jpg" />
  <div class="list_bana">
<!--    <div class="list_bana_l"><img src="/images/31.jpg" /><div class="list_bana_la">   &nbsp;</div></div> -->
   <div class="list_bana_r">
    <dl class="list_bana_ra"><dt><?php echo $info['realname'];?>，欢迎您!</dt><!-- <dt>会员等级:<b style="color:#f30;">&nbsp;A类会员</b></dt> --></dl> 
	<dl class="list_bana_rb"><dt>余额：￥<?php echo $info['money']?></dt></dl> 
	<dl class="list_bana_rb"><dt>积分：<?php echo $info['integral']?></dt></dl>
   </div>
  </div>
 </div>
 <!--dan-->
<div class="member_2">
	<div id="hyzl">
	<h1>
    	<div class="l"><img src="/images/user_36.png" /></div>
        <div class="c">积分兑换记录</div>
    </h1>
    <ul>
    	<style>
		#hyzl ul li em{ color:#888;}
        #hyzl ul li span{ color:#f30;}
        </style>
        <?php 
        	$str=" and userid=$mxuserid and type=2";
        	if(empty($pageindex)){
        		$pageindex=1;
        	}
        	$pagesize=intval($pagesize);
        	if ($pagesize==0){
        		$pagesize=10;
        	}
       		$order="order by createtime desc, id desc";
        	$column=" * ";
        	$biaoid="id";
        	$list=$db->list1($pageindex,$pagesize,'mx_app_user_integral',$column,$str,$order,$biaoid);
        	if(!$list || !is_array($list)){
        		echo '<li><em>暂无信息</em></li>';
        	}else{
        		foreach($list as $k => $v){
        ?>
    	<li><em><?php echo toDate($v['createtime'])?></em><strong style="color:#0C0"><?php echo $v['intro']?></strong>消费<span><?php echo $v['integral']?></span>积分</li>
    	<?php }}?>
    </ul>
<input type="hidden" value="1" id="pageIndex" />
</div>
</div>
 <!--dan-->
<div class="clear"></div>
<script>
$('<div><a href="javascript:void(null);" onclick="pageScroll();" id="gotop" style="background-image: url(\'/images/click_up.png\');background-repeat: no-repeat;bottom: 55px;height: 50px;position: fixed;right: 8px;text-indent: -9999px;visibility: hidden;width: 50px;z-index: 100;"></a></div>').appendTo('body');
function pageScroll(){
	document.getElementById('gotop').style.visibility='hidden';
    //把内容滚动指定的像素数（第一个参数是向右滚动的像素数，第二个参数是向下滚动的像素数）
    window.scrollBy(0,-1000);
    //延时递归调用，模拟滚动向上效果
    scrolldelay = setTimeout('pageScroll()',100);
    //获取scrollTop值，声明了DTD的标准网页取document.documentElement.scrollTop，否则取document.body.scrollTop；因为二者只有一个会生效，另一个就恒为0，所以取和值可以得到网页的真正的scrollTop值
    var sTop=document.documentElement.scrollTop+document.body.scrollTop;
    //判断当页面到达顶部，取消延时代码（否则页面滚动到顶部会无法再向下正常浏览页面）
    if(sTop==0) clearTimeout(scrolldelay);
}
window.onscroll=function(){
    if(($(document).height() - $(window).height())-$(document).scrollTop() < 100){
		//数据请求
		layout();
	}
	
    var sTop=document.documentElement.scrollTop+document.body.scrollTop;
	if(sTop>800){
	    document.getElementById('gotop').style.visibility='visible';
	}else{
	    document.getElementById('gotop').style.visibility='hidden';
	}
}
var tag = true;
/**
 * 获取信息后布局
 * @author Tony
 */
function layout(){
	var pageIndex = parseInt($('#pageIndex').val());
	if(pageIndex && tag){
		tag = false;
		var newPageIndex = pageIndex+1;
		var html = '';
		$.post('outIntegralRecord.php',{'type':'ajax','pageindex':pageIndex+1},function(re){
			tag = true;
			if(re.status == 1){
				$('#pageIndex').val(newPageIndex);
				var list = re.data;
				for(var i=0;i<list.length;i++){
					html += '<li><em>'+list[i].createtime+'</em><strong style="color:#0C0">'+list[i].intro+'</strong>消费<span>'+list[i].integral+'</span>积分</li>';
				}
				$("#hyzl ul>li:last").after(html);
			}else{
				$('#pageIndex').val('0');
			}
		},'json');
	}
}
</script>
<?php require("../w_foot.php")?>